package com.awspaas.user.apps.cpq.event;

import com.actionsoft.bpms.bo.engine.BO;
import com.actionsoft.bpms.bpmn.engine.core.delegate.ProcessExecutionContext;
import com.actionsoft.bpms.bpmn.engine.listener.ExecuteListener;
import com.actionsoft.sdk.local.SDK;
import com.actionsoft.sdk.local.api.BOCopyAPI;
import com.actionsoft.sdk.local.api.BOQueryAPI;

public class ProjectFormAfterCreate extends ExecuteListener{

	public ProjectFormAfterCreate() {
		setDescription("项目报价记录台账中，点击新建按钮后，将默认创建安装费用明细记录数据和将类型值为模板");
	}

	@Override
	public void execute(ProcessExecutionContext pec) throws Exception {
		try {
			String bindId=pec.getProcessInstance().getId();
			BO data=SDK.getBOAPI().query("BO_EU_CPQ_PROJECT_MSG").bindId(bindId).detail();
			if(null!=data) {
				String is=data.getString("SFWMB");
				if(!is.equals("否")) {
					//BOQueryAPI priceQuery=SDK.getBOAPI().query("BO_EU_CPQ_IFT_PRICE");
					SDK.getBOAPI().updateByBindId("BO_EU_CPQ_PROJECT_MSG", bindId, "SFWMB", "是");
					//BOCopyAPI newPrice=priceQuery.copyTo("BO_EU_CPQ_PROJECT_MSG_IFP", bindId);
					///newPrice.exec();
				}
			}else {
				//BOQueryAPI priceQuery=SDK.getBOAPI().query("BO_EU_CPQ_IFT_PRICE");
				SDK.getBOAPI().updateByBindId("BO_EU_CPQ_PROJECT_MSG", bindId, "SFWMB", "是");
				//BOCopyAPI newPrice=priceQuery.copyTo("BO_EU_CPQ_PROJECT_MSG_IFP", bindId);
				//newPrice.exec();
			}
		
		} catch (Exception e) {
			throw e;
		}
		
	}

}
